package com.tianze.tzkf.view;

import android.app.Dialog;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.tianze.tzkf.R;

/**
 * Created by JY on 18/11/28.
 * Google推荐使用DialogFragment(生命周期和activity一致),避免因为activiy 打开的时候结束dialog 引发错误。
 * 对话框
 */

public class ProgressDialog extends DialogFragment {
    public static String TAG=ProgressDialog.class.getSimpleName();
    TextView textView_info;

    String progressInfo =null;

    public ProgressDialog() {
        setStyle(android.support.v4.app.DialogFragment.STYLE_NORMAL, R.style.ProgressDialog);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.dialog_progress, null);
        // setCancelable(false);
        textView_info = (TextView) view.findViewById(R.id.textView_info);
        if(progressInfo !=null){
            textView_info.setText(progressInfo);
        }else {
            textView_info.setVisibility(View.GONE);
        }
        return view;
    }

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        Dialog dialog=super.onCreateDialog(savedInstanceState);
        dialog.setCanceledOnTouchOutside(false);
        return dialog;
    }

    public TextView getTextView_info() {
        return textView_info;
    }

    public void setProgressInfo(String progressInfo) {
        this.progressInfo = progressInfo;
    }

    public String getProgressInfo() {
        return progressInfo;
    }

}
